package com.hsl.study.config;

import com.hsl.study.service.LawAssistant;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: hsl
 * @CreateTime: 2025-04-09-15:11
 * @Version: 1.0
 */

@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig
{
    @Bean
    public ChatLanguageModel chatLanguageModel()
    {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("LANGCHAIN_QIANQWEN"))
                .modelName("qwen-long")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    @Bean
    public LawAssistant lawAssistant(ChatLanguageModel chatLanguageModel) {
        return AiServices.create(LawAssistant.class, chatLanguageModel);
    }
}